﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MySurvey.aspx.cs" Inherits="ValuationClient.NewFolder1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../jquery-easyui-1.5.2/themes/default/easyui.css" rel="stylesheet" />
    <link href="../jquery-easyui-1.5.2/themes/icon.css" rel="stylesheet" />
    <script src="../jquery-easyui-1.5.2/jquery.min.js"></script>
    <script src="../jquery-easyui-1.5.2/jquery.easyui.min.js"></script>
    <script src="../jquery-easyui-1.5.2/easyloader.js"></script>

</head>
<body>
    <div>
        <div id="tb" style="padding: 3px">
            <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="dengji()">登记</a>
            <select class="easyui-combobox" id="select1" style="width: 100px;">
                <option value="0">---请选择---</option>
                <option value="1">所属部门</option>
                <option value="2">项目号</option>
                <option value="3">贷款人</option>
                <option value="4">房屋坐落</option>
            </select>

             <select class="easyui-combobox" id="select2" style="width: 100px;">
                <option value="0">---请选择---</option>
           
            </select>
            <a href="#" class="easyui-linkbutton" plain="true" onclick="SelctBasic1()">查询</a>
        </div>
        <table id="dg" class="easyui-datagrid" url="" iconcls="icon-search" toolbar="#tb" rownumbers="true" pagination="true"></table>
    </div>
</body>
</html>
<script>

    function dengji()
    {
        parent.addTab('登记借款人基本信息', "ProjectApproval/Register.aspx", "", true);
    }
    $(function () {
        SelctBasic();
        
    })

    //立项显示
    function SelctBasic() {
        var id = $("#select1").combobox('getValue');
        var name = "";
        $.ajax({
            type: "get",
            url: "http://localhost:55439/api/Project/GetBasicInfo/?id="+id+"&name="+name,
            dataType: "json",
            success: function (obj) {
                obj = eval(obj);
                $("#dg").datagrid({
                    pagination: true,
                    data: obj.slice(0, 10),
                    striped: true,
                    columns: [[
                        { field: "projectNumber", width: 150, title: '项目编号', align: 'center', closed: true },
                        { field: "Department_Name", width: 150, title: '所属部门', align: 'center' },
                        { field: "loan_Name", width: 150, title: '借款人', align: 'center' },
                        { field: "loan_TEL", width: 150, title: '借款人联系电话', align: 'center' },
                        { field: "basic_Quota", width: 150, title: '贷款额度', align: 'center' },
                        { field: "RegisterTime", width: 150, title: '登记时间', align: 'center' },
                        {
                            field: "basic_State", width: 150, title: '项目状态', align: 'center',
                            formatter: function (value, row, index) {
                                //也可用 formatter: function (value, rec) {
                                return row.basic_State == 0 ? '待勘察' : row.basic_State == 1 ? "勘察中" : row.basic_State == 2 ? "待审核" : row.basic_State == 3 ? "初审核中" : row.basic_State == 4 ? "终审通过" : ""
                            }
                        },
                    ]]
                });
                //分页
                var pager = $("#dg").datagrid("getPager");
                pager.pagination({
                    beforePageText: '第',//页数文本框前显示的汉字 
                    afterPageText: '页 共 {pages} 页',
                    displayMsg: '共{total}条数据',
                    total: obj.length,
                    onSelectPage: function (pageNo, pageSize) {
                        var start = (pageNo - 1) * pageSize;
                        var end = start + pageSize;
                        $("#dg").datagrid("loadData", obj.slice(start, end));
                        pager.pagination('refresh', {
                            total: obj.length,
                            pageNumber: pageNo
                        });
                    }
                });
            }
        })
    }

    //查询
    function SelctBasic1() {
        var id = $("#select1").combobox('getValue');
        var name = $("#select2").combobox('getText');
        $.ajax({
            type: "get",
            url: "http://localhost:55439/api/Project/GetBasicInfo/?id=" + id + "&name=" + name,
            dataType: "json",
            success: function (obj) {
                obj = eval(obj);
                $("#dg").datagrid({
                    pagination: true,
                    data: obj.slice(0, 10),
                    striped: true,
                    columns: [[
                        { field: "projectNumber", title: '项目编号', align: 'center', closed: true },
                        { field: "Department_Name", title: '所属部门', align: 'center' },
                        { field: "loan_Name", title: '借款人', align: 'center' },
                        { field: "loan_TEL", title: '借款人联系电话', align: 'center' },
                        { field: "basic_Quota", title: '贷款额度', align: 'center' },
                        { field: "RegisterTime", title: '登记时间', align: 'center' },
                        {
                            field: "basic_State", width: 150, title: '项目状态', align: 'center',
                            formatter: function (value, row, index) {
                                //也可用 formatter: function (value, rec) {
                                return row.basic_State == 0 ? '待勘察' : row.basic_State == 1 ? "勘察中" : row.basic_State == 2 ? "待审核" : row.basic_State == 3 ? "初审核中" : row.basic_State == 4 ? "终审通过" : ""
                            }
                        },
                    ]]
                });
                //分页
                var pager = $("#dg").datagrid("getPager");
                pager.pagination({
                    beforePageText: '第',//页数文本框前显示的汉字 
                    afterPageText: '页 共 {pages} 页',
                    displayMsg: '共{total}条数据',
                    total: obj.length,
                    onSelectPage: function (pageNo, pageSize) {
                        var start = (pageNo - 1) * pageSize;
                        var end = start + pageSize;
                        $("#dg").datagrid("loadData", obj.slice(start, end));
                        pager.pagination('refresh', {
                            total: obj.length,
                            pageNumber: pageNo
                        });
                    }
                });
            }
        })
    }

    //下拉联动
    $("#select1").combobox({
        onChange: function () {
            var id = $("#select1").combobox('getValue');
            //所属部门
            if (id == 1) {
                $.ajax({
                    type: "get",
                    url: "http://localhost:55439/api/Project/SelectBasic",
                    async: false,
                    success: function (obj) {
                        obj = eval(obj);
                    
                        $("#select2").combobox({
                            data: obj,
                            valueField: 'Department_Id',
                            textField: 'Department_Name',
                            onLoadSuccess: function () {
                                $("#select2").combobox('select', '-----请选择-----');
                            }
                        })
                    }
                })
            }
            //项目号
            if (id == 2) {
                $.ajax({
                    type: "get",
                    url: "http://localhost:55439/api/Project/SelectBasic",
                    async: false,
                    success: function (obj) {
                        obj = eval(obj);
                        $("#select2").combobox({
                            data: obj,
                            valueField: 'basic_id',
                            textField: 'projectNumber',
                            onLoadSuccess: function () {
                                $("#select2").combobox('select', '-----请选择-----');
                            }
                        })
                    }
                })
            }
            //借款人
            if (id == 3) {
                $.ajax({
                    type: "get",
                    url: "http://localhost:55439/api/Project/SelectBasic",
                    async: false,
                    success: function (obj) {
                        obj = eval(obj);
                        $("#select2").combobox({
                            data: obj,
                            valueField: 'loan_Name',
                            textField: 'loan_Name',
                            onLoadSuccess: function () {
                                $("#select2").combobox('select', '-----请选择-----');
                            }
                        })
                    }
                })
            }
            //房屋坐落
            if (id == 4) {
                $.ajax({
                    type: "get",
                    url: "http://localhost:55439/api/Project/SelectBasic",
                    async: false,
                    success: function (obj) {
                        obj = eval(obj);
                        $("#select2").combobox({
                            data: obj,
                            valueField: 'house_Located',
                            textField: 'house_Located',
                            onLoadSuccess: function () {
                                $("#select2").combobox('select', '-----请选择-----');
                            }
                        })
                    }
                })
            }
        }
    })
</script>

